//
//  EMSearchBar.m
//  ElectronicMall
//
//  Created by 史伟文 on 14/12/22.
//  Copyright (c) 2014年 cczu. All rights reserved.
//

#import "EMSearchBar.h"

@implementation EMSearchBar

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        _rect = frame;
        
    }
    return self;
}

- (void)setPlaceholderText:(NSString *)placeholderText
{
    _placeholderText = placeholderText;
    [self drawSearchBar:_rect];
}
- (void)drawSearchBar:(CGRect)frame
{
    CGRect textFieldFrame = frame;
    textFieldFrame.size.width = frame.size.width - 30;
    UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 140, 24)];
    UIImage *img = [UIImage imageNamed:@"背景_导航_搜索"];
    textField.backgroundColor = [UIColor colorWithPatternImage:img];
    textField.placeholder = _placeholderText;
    textField.font = [UIFont fontWithName:HEITILIGHT size:12];
    [self addSubview:textField];
    
    CGRect searchIconFrame;
    searchIconFrame.origin.x = 120;
    searchIconFrame.origin.y = 5;
    searchIconFrame.size.width = 16;
    searchIconFrame.size.height = 16;
    
    UIImageView *searchImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_导航_搜索"]];
    searchImage.frame = searchIconFrame;
    [self addSubview:searchImage];
}
@end
